/**
 * Copyright &copy; 2016-2017 <a href="https://www.lczyfz.com">联创智云</a> All rights reserved.
 */
package com.lczyfz.campusinfo.modules.campusinfo.web;

import com.lczyfz.campusinfo.common.utils.ApiResultUtils;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.campusinfoeducation.entity.CampusinfoAbroad;
import com.lczyfz.campusinfo.modules.campusinfoeducation.entity.CampusinfoPubmed;
import com.lczyfz.campusinfo.modules.campusinfoeducation.service.CampusinfoAbroadService;
import com.lczyfz.campusinfo.modules.campusinfoeducation.service.CampusinfoPubmedService;
import com.lczyfz.campusinfo.modules.campusinfoexam.entity.CampusinfoExam;
import com.lczyfz.campusinfo.modules.campusinfoexam.entity.CampusinfoServant;
import com.lczyfz.campusinfo.modules.campusinfoexam.entity.CampusinfoTrain;
import com.lczyfz.campusinfo.modules.campusinfoexam.service.CampusinfoExamService;
import com.lczyfz.campusinfo.modules.campusinfoexam.service.CampusinfoServantService;
import com.lczyfz.campusinfo.modules.campusinfoexam.service.CampusinfoTrainService;
import com.lczyfz.campusinfo.modules.creatjobmanage.entity.CreatJobProject;
import com.lczyfz.campusinfo.modules.creatjobmanage.entity.CreatPartProject;
import com.lczyfz.campusinfo.modules.creatjobmanage.service.CreatJobProjectService;
import com.lczyfz.campusinfo.modules.creatjobmanage.service.CreatPartProjectService;
import com.lczyfz.campusinfo.modules.jobmesmanage.entity.JobMesSearch;
import com.lczyfz.campusinfo.modules.jobmesmanage.entity.StuJobSearch;
import com.lczyfz.campusinfo.modules.jobmesmanage.service.JobMesSearchService;
import com.lczyfz.campusinfo.modules.jobmesmanage.service.StuJobSearchService;
import com.lczyfz.campusinfo.modules.sys.security.SystemAuthorizingRealm;
import com.lczyfz.campusinfo.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 勤工视图Controller
 * @author zms
 * @version 2018-04-01
 */
@Controller
@RequestMapping(value = "/api/schoolSource/enlist")
public class StuJobApiSearchController extends BaseController {

	@Autowired
	private StuJobSearchService stuJobSearchService;
	@Autowired
	private JobMesSearchService jobMesSearchService;
	@Autowired
	private CreatJobProjectService creatJobProjectService;
	@Autowired
	private CreatPartProjectService creatPartProjectService;

	@Autowired
	private CampusinfoExamService campusinfoExamService;
	@Autowired
	private CampusinfoAbroadService campusinfoAbroadService;
	@Autowired
	private CampusinfoPubmedService campusinfoPubmedService;
	@Autowired
	private CampusinfoServantService campusinfoServantService;
	@Autowired
	private CampusinfoTrainService campusinfoTrainService;
	@RequestMapping(value = "jobList" ,method = RequestMethod.POST)
	@ResponseBody    //获取报名信息
	public Map<String, Object> getNotice( HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> map = ApiResultUtils.getBaseMapSuccess();
		SystemAuthorizingRealm.Principal principal = UserUtils.getPrincipal(); //判断用户是否掉线
		if (principal!=null) {
			CampusinfoAbroad campusinfoAbroad = new CampusinfoAbroad();
			CampusinfoPubmed campusinfoPubmed = new CampusinfoPubmed();
			CampusinfoServant campusinfoServant = new CampusinfoServant();
			CampusinfoExam campusinfoExam = new CampusinfoExam();
			CampusinfoTrain campusinfoTrain = new CampusinfoTrain();
			campusinfoExam.setUser(UserUtils.getUser());   //模拟的
			campusinfoPubmed.setUser(UserUtils.getUser()); //考研的
			campusinfoTrain.setUser(UserUtils.getUser()); //考证的
			StuJobSearch stuJobSearch = new StuJobSearch();
			JobMesSearch jobMesSearch = new JobMesSearch();
			stuJobSearch.setUserId(principal.toString()); //勤工的
			jobMesSearch.setUserId(principal.toString());  //就业的
			campusinfoServant.setUser(UserUtils.getUser());  //考公的
			campusinfoAbroad.setUserId(principal.toString()); //出国的
			CreatJobProject creatJobProject = new CreatJobProject();
			creatJobProject.setUpId(principal.toString()); //创业（自带）
			CreatPartProject creatPartProject = new CreatPartProject();
			creatPartProject.setUpId(principal.toString());  //创业（园区）
			List<StuJobSearch> stuJobSearches = stuJobSearchService.findList(stuJobSearch);
			List<JobMesSearch> jobMesSearches = jobMesSearchService.findList(jobMesSearch);
			List<CreatJobProject> creatJobProjects = creatJobProjectService.findList(creatJobProject);
			List<CreatPartProject> CreatPartProjects = creatPartProjectService.findList(creatPartProject);
			List<CampusinfoAbroad> campusinfoAbroads = campusinfoAbroadService.findList(campusinfoAbroad);//出国的报名
			List<CampusinfoPubmed> campusinfoPubmeds = campusinfoPubmedService.findList(campusinfoPubmed); //考研的报名
			List<CampusinfoServant> campusinfoServants = campusinfoServantService.findList(campusinfoServant); //考公务报名
			List<CampusinfoExam> campusinfoExams = campusinfoExamService.findList(campusinfoExam); //模拟考试报名信息
			List<CampusinfoTrain> campusinfoTrains = campusinfoTrainService.findList(campusinfoTrain); //培训报名信息
			map.put("stuJobSearches", stuJobSearches); //勤工的报名信息
			map.put("jobMesSearches", jobMesSearches);  //出国的报名信息
			map.put("creatJobProjects", creatJobProjects); //创业的报名信息（自带）
			map.put("CreatPartProjects", CreatPartProjects); //创业的报名信息（园区)
			map.put("campusinfoAbroads", campusinfoAbroads); //出国的报名信息
			map.put("campusinfoPubmeds", campusinfoPubmeds); //考研的报名信息
			map.put("campusinfoExams", campusinfoExams); //模拟考试的报名信息
			map.put("campusinfoServants",campusinfoServants); //公务员考试报名信息
			map.put("campusinfoTrains", campusinfoTrains); //考证的
			map.put("success",true);
			return map;
		} else {
			map.put("success",false); //没有用户的信息
			map.put("message","没有用户信息");
		}
       return  map;
	}
}